package com.heima.test17;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class FileUploadClient {
    public static void main(String[] args) throws IOException, InterruptedException {
        //1 连接服务器
        Socket socket = new Socket("127.0.0.1", 20000);

        // 获取输出流 用来发送图片数据
        OutputStream os = socket.getOutputStream();

        //2 读取文件 111.png
        FileInputStream fis = new FileInputStream("111.png");
        byte[] bytes = new byte[1024];
        int len;
        while ((len = fis.read(bytes)) != -1) {
            //3 把每次读取的数据 通过socket发出去
            os.write(bytes, 0, len);
            Thread.sleep(1000);
        }
        fis.close();
        os.close();
        socket.close();
    }
}
